package com.chap17.completablefuture;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;

/**
 * <p>
 * <code>Demo09</code>
 * </p>
 *
 * @author junbao3
 * TODO
 * @date 2023-05-10 8:31
 * Copyright (C) 2021 IFlyTek. All rights reserved.
 */
@Slf4j
public class Demo09 {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        CompletableFuture<Integer> cf = CompletableFuture.supplyAsync(() -> {
            int result = 100;
            log.debug("一阶段：{}", result);
            return result;
        }).thenApply(num -> {
            int result = num * 3;
            log.debug("二阶段：{}", result);
            return result;
        });

        System.out.println("最终结果："+ cf.get());
    }
}
